package dao;

import hibernateUtils.HibernateUtil;

import org.hibernate.Session;
import org.hibernate.SessionFactory;

import beans.PlatoBean;

public class HibernatePlatoDAO {

	private static HibernatePlatoDAO instancia;
	private static SessionFactory sf;

	public static HibernatePlatoDAO getInstancia() {
		if (instancia == null) {
			sf = HibernateUtil.getSessionFactory();
			instancia = new HibernatePlatoDAO();
		}
		return instancia;
	}

	public PlatoBean getPlato(int id) {
		Session session = sf.openSession();

		PlatoBean plato = (PlatoBean) session.get(PlatoBean.class, id);
		session.close();
		return plato;

	}

}
